package com.suarte.webapp.action;

import com.suarte.core.service.CompanyManager;
import java.io.Serializable;
import java.util.List;

/**
 * @date   Dec 20, 2010
 * @author Ggutierrez
 */
public class CompanyList extends BasePage implements Serializable {

    private CompanyManager companyManager;
    private List companies;
    private String description;

    public void setCompanyManager(CompanyManager companyManager) {
        this.companyManager = companyManager;
    }

    public CompanyList() {
        setSortColumn("id"); // sets the default sort column
    }

    public String execute() {
        companies = sort(companyManager.findCompanies(description));
        return "list";
    }

    public List getCompanies() {
        companies = companyManager.findCompanies(description);
        if (companies != null) {
            return sort(companies);
        } else {
            return companies;
        }
    }

    public void setCompanies(List companies) {
        this.companies = companies;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
